<?php
include"config.php";
		$one_day = $_POST['one_day'];
		$three_day = $_POST['three_day'];
		$seven_day = $_POST['seven_day'];
		$thirty_day = $_POST['thirty_day'];
		
		$point_unit = $_POST['point_unit'];
		$point_price = $_POST['point_price'];
	
		$id = $_POST['id'];
		$namafolder="assets/picture/";
		$item_name=$_POST['item_name'];
		$cattegory = $_POST['cattegory'];
		$mark = $_POST['mark'];
		
		$damage = $_POST['damage'];
		$fire_speed = $_POST['fire_speed'];
		$accuracy = $_POST['accuracy'];
		$ammo_1 = $_POST['ammo_1'];
		$ammo_2 = $_POST['ammo_2'];
		$v_recoil = $_POST['v_recoil'];
		$h_recoil = $_POST['h_recoil'];
		$move_speed = $_POST['move_speed'];
		$ranger = $_POST['ranger'];
		$status = $_POST['status'];
				
		
			
		
			if (!empty($_FILES["picture"]["tmp_name"])){
				$jenis_gambar = $_FILES['picture']['type'];
				//echo $jenis_gambar;
				
				//echo "$duration<br />";
				//echo $item_weapon;
				if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png"){
					//echo"a";
					$gambar = $namafolder . basename($_FILES['picture']['name']);
					$judul_gambarnya = $_FILES['picture']['name'];
					if (move_uploaded_file($_FILES['picture']['tmp_name'], $gambar)){
						//echo"b";
						$sql="update tbl_weapon set picture = '$judul_gambarnya', item_weapon = '$item_weapon', cattegory = '$cattegory', mark = '$mark', tipe = '$tipe', point_unit = '$point_unit', point_price = '$point_price',  one_day = '$one_day', three_day = '$three_day', seven_day = '$seven_day', thirty_day = '$thirty_day',  damage = '$damage', fire_speed = '$fire_speed', accuracy = '$accuracy', ammo_1 = '$ammo_1', ammo_2 = '$ammo_2', v_recoil = '$v_recoil', h_recoil = '$h_recoil', move_speed = '$move_speed', ranger = '$ranger', status = '$status' where id_weapon = '$id'";
						$res=mysql_query($sql) or die (mysql_error());
						
						header("location:index.php?page=weapon");
					}else{
						echo "Gambar gagal dikirim";
					}
				}else{
					echo "Jenis gambar yang anda kirim salah. Harus .jpg .gif .png";
			}
					}else{
						$sql="update tbl_weapon set item_name = '$item_name', cattegory = '$cattegory', mark = '$mark', point_unit = '$point_unit', point_price = '$point_price', one_day = '$one_day', three_day = '$three_day', seven_day = '$seven_day', thirty_day = '$thirty_day',  damage = '$damage', fire_speed = '$fire_speed', accuracy = '$accuracy', ammo_1 = '$ammo_1', ammo_2 = '$ammo_2', v_recoil = '$v_recoil', h_recoil = '$h_recoil', move_speed = '$move_speed', ranger = '$ranger', status = '$status' where id_weapon = '$id'";
						$res=mysql_query($sql) or die (mysql_error());
						
						header("location:index.php?page=weapon");
					}
?>